import 'package:course_control/config/styles.dart';
import 'package:course_control/gen/assets.gen.dart';
import 'package:course_control/widgets/backgroud_widget.dart';
import 'package:course_control/widgets/primary_button.dart';
import 'package:course_control/widgets/wifi_widget.dart';
import 'package:flutter/material.dart';
import 'package:flutter_utils/flutter_utils.dart';
import 'package:flutter_widgets/flutter_widgets.dart';
import 'package:from_css_color/from_css_color.dart';
import 'package:get/get.dart';
import '../controllers/start_controller.dart';

class StartView extends GetView<StartController> {
  const StartView({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: BackgroundWidget(
        child: Stack(
          children: [
            Positioned(
              left: 0,
              right: 0,
              top: 0,
              child: Center(
                child: Text('高三1班（12-56）', style: TextStyles.titleStyle),
              ),
            ),
            Positioned(
              right: 20.ratio,
              top: 20.ratio,
              child: const WifiWidget(),
            ),
            Center(
              child: Column(
                mainAxisAlignment: MainAxisAlignment.center,
                children: [
                  Obx(() {
                    return Text(
                      controller.timeStr.value,
                      style: TextStyle(
                          fontSize: 156.ratio,
                          color: Colors.white,
                          fontWeight: FontWeight.bold),
                    );
                  }),
                  Obx(() {
                    return Text(
                      controller.dateTimeStr.value,
                      style: TextStyles.titleStyle,
                    );
                  }),
                  SizedBox(
                    height: 70.ratio,
                  ),
                  PrimaryButton(
                    width: 366.ratio,
                    height: 120.ratio,
                    onPressed: controller.onStartCourse,
                    child: Text('开始上课', style: TextStyles.titleStyle),
                  ),
                ],
              ),
            ),
            Positioned(
              right: 40.ratio,
              bottom: 40.ratio,
              child: _buildBorderButton(),
            )
          ],
        ),
      ),
    );
  }

  Widget _buildBorderButton() {
    return PrimaryButton.warp(
      child: Container(
        width: 184.ratio,
        height: 60.ratio,
        decoration: BoxDecoration(
          color: fromCssColor('#3574E3').withOpacity(0.3),
          border: Border.all(color: fromCssColor('#3574E3'), width: 2.ratio),
          borderRadius: BorderRadius.circular(4.ratio),
        ),
        child: Row(
          mainAxisAlignment: MainAxisAlignment.spaceEvenly,
          children: [
            CommonImage.asset(Assets.images.iconPhone.path, width: 20.ratio),
            Text(
              '呼叫管理员',
              style: TextStyles.textStyle20,
            )
          ],
        ),
      ),
    );
  }
}
